package org.dromara.common.encrypt.core.encryptor

import org.dromara.common.encrypt.core.EncryptContext
import org.dromara.common.encrypt.enumd.AlgorithmType
import org.dromara.common.encrypt.enumd.EncodeType
import org.dromara.common.encrypt.utils.EncryptUtils.decryptByBase64
import org.dromara.common.encrypt.utils.EncryptUtils.encryptByBase64

/**
 * Base64算法实现
 *
 * @author 老马
 * @version 4.6.0
 * @updater LikeYouDo
 * @date 2025/1/9 10:00
 */
open class Base64Encryptor(
    context: EncryptContext
) : AbstractEncryptor(context) {

    /**
     * 获得当前算法
     */
    override fun algorithm() = AlgorithmType.BASE64

    /**
     * 加密
     *
     * @param value      待加密字符串
     * @param encodeType 加密后的编码格式
     */
    override fun encrypt(value: String?, encodeType: EncodeType?): String =
        encryptByBase64(value)

    /**
     * 解密
     *
     * @param value      待加密字符串
     */
    override fun decrypt(value: String?): String =
        decryptByBase64(value)

}
